package com.inforich.appManage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.inforich.appManage.mapper.AppRoleMapper;
import com.inforich.appManage.domain.AppRole;
import com.inforich.appManage.service.IAppRoleService;

/**
 * app角色Service业务层处理
 *
 * @author hjm
 * @date 2022-10-27
 */
@Service
public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> implements
    IAppRoleService {

  @Override
  public Page<AppRole> pageAppRole(Page<AppRole> page, Map<String, Object> map) {
    return baseMapper.pageAppRole(page, map);
  }

  @Override
  public List<AppRole> listAppRole(Map<String, Object> map) {
    return baseMapper.listAppRole(map);
  }

  @Override
  public AppRole getByRoleCode(String roleCode) {
    return this.getOne(new LambdaQueryWrapper<AppRole>().eq(AppRole::getRoleCode, roleCode));
  }

  @Override
  public String getIdByRoleCode(String roleCode) {
    AppRole appRole = getByRoleCode(roleCode);
    return appRole == null ? "" : appRole.getId();
  }

  @Override
  public String getRoleCodeById(String id) {
    AppRole appRole = getById(id);
    return appRole == null ? "" : appRole.getRoleCode();
  }


}
